﻿package net.wangit.jdbc.sqltype;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

import net.wangit.jdbc.util.SqlDateUtil;


public class TimeSqlType extends NullableSqlType {

	private static final long serialVersionUID = 1L;

	public TimeSqlType() {
	}

	public String get(ResultSet rs, String name) throws SQLException {
		Object temp = rs.getObject(name);
		return temp != null ? temp.toString() : null;
	}

	public void setNotNull(PreparedStatement st, String value, int index)
			throws SQLException {
		if ("".equals(value))
			st.setNull(index, sqlType());
		else
			st.setTime(index, SqlDateUtil.getSqlTime(value));
	}

	public int sqlType() {
		return Types.TIME;
	}
}
